from rich.console import Console
from rich.table import Table
from rich.prompt import Prompt
import argparse

console = Console()
parser = argparse.ArgumentParser()
parser.add_argument("--theme", choices=["dark", "light"], default="dark")
args = parser.parse_args()

# 动态切换主题
theme = {"dark": "monokai", "light": "github"}[args.theme]
console.print(f"[bold {theme}]已加载主题:[/{theme}]")

# 生成动态表格
data = [{"name": f"Item {i}", "price": 10+i*5} for i in range(5)]
table = Table(title="商品列表", show_header=True)
table.add_column("名称", style="cyan")
table.add_column("价格", justify="right", style="green")
for item in data:
    table.add_row(item["name"], f"${item['price']}")

console.print(table)